package com.tan.steamship.controller;

import com.tan.steamship.common.Result;
import com.tan.steamship.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 收藏
 * @author: longshifu
 * @time: 2025/3/6 22:09
 */
@RestController
@RequestMapping("/collect/v1")
public class CollectController {
    @Autowired
    CollectService collectService;

    /**
     * 获取用户收藏
     * @param userId
     * @return 返回商品集合
     */
    @GetMapping("/user/{userId}")
    public Result getCollect(@PathVariable Integer userId) {
        return Result.success(collectService.getAllCollect(userId));
    }

    @PostMapping("/user/{routeId}/{userId}")
    public Result addCollect(@PathVariable Integer routeId , @PathVariable Integer userId ) {
        return collectService.addCollect(routeId, userId);
    }

    @DeleteMapping("/user/{routeId}/{userId}")
    public Result deleteCollect(@PathVariable  Integer routeId , @PathVariable Integer userId) {
        collectService.deleteCollect(routeId, userId);
        return Result.success("删除收藏成功");
    }
}
